﻿/**
 * @brief     鏃堕棿绠＄悊宸ュ叿
 * @details
 * @author    Yin
 * @version   1.0
 * @date
 * @copyright
 * @note
 */

#ifndef TIMEUTIL_H
#define TIMEUTIL_H

#include <QObject>

#include "common_global.h"

namespace Common {

class COMMONSHARED_EXPORT TimeUtil
{
public:

    /*!< 鏃堕棿鎴炽€佹椂闂?*/
    /**
     * @brief getTimeStamp
     * @param format
     * @return
     */
    static QString getTimeStamp(QString format = "yyyy-MM-dd hh:mm:ss.zzz");

    /**
     * @brief getDate
     * @param format
     * @return
     */
    static QString getDate(QString format = "yyyy-MM-dd");

    /**
     * @brief getTime
     * @param format
     * @return
     */
    static QString getTime(QString format = "hh:mm:ss.zzz");

    /**
     * @brief timeStamp
     * @return
     */
    static qint64 timeStamp();

    /**
     * @brief currentMSecsSinceEpoch
     * @return
     */
    static qint64 currentMSecsSinceEpoch();

    /*!
     * @brief 鑾峰彇褰撳墠鏃堕棿鑷牸鏋楀凹娌绘椂闂?970-1-1 8:0:0浠ユ潵鐨勭鏁?
     * @details QDateTime浼氬厛灏嗕袱涓椂闂撮兘杞崲涓篻mt鏃堕棿锛屽啀鍋氭瘮杈冦€?
     */
    static qint64 currentSecsSinceEpoch();

    /*!
     * @brief RUtil::addMSecsToEpoch 灏嗘绉掓暟鍔犱笂鏍兼灄灏兼不鏃堕棿涓哄疄闄呮椂闂?
     * @param[in] mSeonds 鏍兼灄灏兼不鏃堕棿浠ユ潵鐨勬绉掓暟
     * @return 瀹為檯鏃堕棿
     */
    static QDateTime addMSecsToEpoch(qint64 mSeonds);

    /*!
     * @brief RUtil::addMSecsToEpoch 灏嗙鏁板姞涓婃牸鏋楀凹娌绘椂闂翠负瀹為檯鏃堕棿
     * @param[in] mSeonds 鏍兼灄灏兼不鏃堕棿浠ユ潵鐨勭鏁?
     * @return 瀹為檯鏃堕棿
     */
    static QDateTime addSecsToEpoch(qint64 seonds);

    static  QString secondFormatHHMMSS(qint64 second);

    static  QString millisecondFormatHHMMSS(qint64 ms);

};

}//namespace Common

#endif // TIMEUTIL_H
